#include "header.h"
Cluster::Cluster()
{
}

Cluster::Cluster(const char *clusterIdMapFile, const char* clusterFile, int docNum)
{
    this->load(clusterIdMapFile, clusterFile, docNum);
}

void Cluster::load(const char *clusterIdMapFile, const char* clusterFile, int docNum)
{
    if (strlen(clusterIdMapFile) < 1) {
        cout << "clusterIdMapFile is empty!" << endl;
        exit(1);
    }
    if (strlen(clusterFile) < 1) {
        cout << "clusterFile is empty!" << endl;
        exit(1);
    }
    this->docNum = docNum;
    this->qIdClusterIdMap.resize(docNum+1);
    this->clusters.resize(docNum+1);
    //加载qid-clusterId 映射文件
    int mapNum = loadIntVector(clusterIdMapFile, this->qIdClusterIdMap);
    cout << "Finish reading " << mapNum << " qId-clusterId!" << endl;
    //加载cluster对应的id集合
    int clusterNum = loadIntVectorArray(clusterFile, this->clusters);
    cout << "clusterFile:" << clusterFile << endl;
    cout << "Finish reading " << clusterNum << " clusters!" << endl;
}

Cluster::~Cluster()
{
   this->qIdClusterIdMap.clear();
   this->clusters.clear();
}
